﻿// Inner Fire 游戏引擎库
// InstancedSpriteObject - 实例精灵对象
//
// Copyright (c) 2025 by 尔西大帝. All rights reserved.
//
// 所属层级：应用层（4）
// 用于管理一系列的实例精灵
//
// Author: 尔西大帝
// Email: 2670613871@qq.com
// Created: 2025-05-21

#include "instanced_sprite_object.h"

namespace ifire::game {
InstancedSpriteObject::InstancedSpriteObject(
    ikit::sstr name, Scene* scene, GameObject* parent)
    : GameObject(name, scene, parent) {}

InstancedSpriteObject::~InstancedSpriteObject() {}

void InstancedSpriteObject::FixedUpdate() {}

void InstancedSpriteObject::SetPosition(int index, IVec3 position) {
  pool_->SetPosition(index, position);
}

void InstancedSpriteObject::SetTransform(
    int index, IVec3 position, IVec4 rotation, IVec3 scale) {
  pool_->SetTransform(index, position, rotation, scale);
}

void InstancedSpriteObject::SetColor(int index, IVec4 color) {
  pool_->SetColor(index, color);
}

void InstancedSpriteObject::SetLine(
    int index, IVec3 position, IVec3 end) {
  pool_->SetLine(index, position, end);
}

void InstancedSpriteObject::SetDrawCount(size_t draw_count) {
  pool_->SetDrawCount(draw_count);
}

void InstancedSpriteObject::SetRefresh() {
  // 将Transform的信息同步到pool的Transform
  DirectX::XMStoreFloat4x4(&pool_->world, GetTransform().mat);
  pool_->SetRefresh();
}

void InstancedSpriteObject::SetAllScale(IVec3 scale) {
  pool_->scale = scale;
  pool_->SetRefresh();
}

void InstancedSpriteObject::SetAllColor(IVec4 color, int start, int end) {
  pool_->color = color;
  pool_->SetAllColor(color, start, end);
  pool_->SetRefresh();
}

} // namespace ifire::game